package com.excilys.sae.apptest;

import java.util.List;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.excilys.sae.dao.UserDetailsDAO;
import com.excilys.sae.entity.UserDetails;

public class Main {
	
	public static void main(String[] args) {
	
		ApplicationContext ac = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
				
		UserDetailsDAO userDetailsDAO = (UserDetailsDAO) ac.getBean("userDetailsDao", UserDetailsDAO.class);
		
		List<UserDetails> userDetailsList = userDetailsDAO.getAllUserDetails();
		
		for(UserDetails userDetails:userDetailsList){
			System.out.println("Username : " + userDetails.getUserName());
		}
		
		UserDetails user = userDetailsDAO.getUserDetailsByUsername("gael");
		System.out.println("User : " + user.getAddress());
		
	}	

}
